<?php
import("ORG.Util.Session");
// 本类由系统自动生成，仅供测试用途
class InfoAction extends Action {

   private function checkLogin(){			//判断是否登陆 否则切到登陆界面
		session_start();
		if($_SESSION['online']==null){
			$this -> redirect('Login/index');
			exit;
		}
		return true;
	}

	public function article(){
		$this->login();
		$this->display();
	}

	public function gaikuang(){
        $this->login();//登陆
		$article=M('article');
		$cond['isindex']='1';
		$cond['type']='大厅简介';
		$index=$article->where($cond)->select();
		$dtjs=$index[0]['content'];
		//dump($dtjs);
		$this->assign('dtjs',$dtjs);
		$this->display();
    }
	public function modifygaikuang(){
		$this->checkLogin();
		$article=M('article');
		$data=array(
		'content'=>$_POST['content']
		);
		$article->where('type="大厅简介"')->setField($data);
		$this->success('修改成功');
	}

	public function zhidu(){
        $this->login();//登陆
		$article=M('article');
		$cond['type']='工作制度';
		$index=$article->where($cond)->select();
		$gzzd=$index[0]['content'];
		$this->assign('gzzd',$gzzd);
		$this->display();
    }
	public function modifyzhidu(){
		$this->checkLogin();
		$article=M('article');
		$data=array(
		'content'=>$_POST['content']
		);
		$article->where('type="工作制度"')->setField($data);
		$this->success('修改成功');
	}

	public function tuandui(){
        $this->login();//登陆
		$article=M('article');
		$cond['type']='建设团队';
		$index=$article->where($cond)->select();
		$jstd=$index[0]['content'];
		$this->assign('jstd',$jstd);
		$this->display();
    }
	public function modifytuandui(){
		$this->checkLogin();
		$article=M('article');
		$data=array(
		'content'=>$_POST['content']
		);
		$article->where('type="建设团队"')->setField($data);
		$this->success('修改成功');
	}

	public function lamp(){
        $this->login();//登陆
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='最美大厅';
		$index=$article->where($cond)->count();
		$Page = new Page($index,7);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d h:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
    }


	public function gangwei(){
		$this->login();//登陆
		$article=M('article');
		$i=$_GET['id'];
		$i=$i+10;
		$cond['type']='岗位介绍';
		$cond['id']=$i;
		$index=$article->where($cond)->select();
		$gwjs=$index[0]['content'];
		$this->assign('gwjs',$gwjs);
		$this->display();
    }
	public function modifygangwei(){
		$this->checkLogin();
		$article=M('article');
		$id=$_POST['id']+10;
		//dump($_POST);
		$data=array(
		'content'=>$_POST['content']
		);
		$cond['type']="岗位介绍";
		$cond['id']=$id;
		$article->where($cond)->setField($data);
		$this->success('修改成功');
	}

	public function gangweitel(){
		$this->login();//登陆
		$article=M('article');
		$i=$_GET['id'];
		$i=$i+10;
		$cond['type']='岗位介绍';
		$cond['id']=$i;
		$index=$article->where($cond)->select();
		$gwjs=$index[0]['author'];
		$this->assign('gwjs',$gwjs);
		$this->display();
	}
	public function modifygangweitel(){
		$this->checkLogin();
		$article=M('article');
		$id=$_POST['id']+10;
		//dump($_POST);
		$data=array(
		'author'=>$_POST['content']
		);
		$cond['type']="岗位介绍";
		$cond['id']=$id;
		$article->where($cond)->setField($data);
		$this->success('修改成功');
	}

	public function searchindex(){
		$this->login();//登陆
		$article=M('article');
		$i=$_GET['id'];
		$i=$i+10;
		$cond['type']='岗位介绍';
		$cond['id']=$i;
		$index=$article->where($cond)->select();
		$gwjs=$index[0]['title'];
		$this->assign('gwjs',$gwjs);
		$this->display();
	}
	public function modifyschindex(){
		$this->checkLogin();
		$article=M('article');
		$id=$_POST['id']+10;
		//dump($_POST);
		$data=array(
		'title'=>$_POST['cont']
		);
		$cond['type']="岗位介绍";
		$cond['id']=$id;
		$article->where($cond)->setField($data);
		$this->success('修改成功');
	}






	/*----------------文章发布系统
	此系统是一个综合的文章发布系统，可以发布几乎任何类型的文章，并支持图片
	------------------------------
	*/
	public function newarticle(){
		$this->login();
		$time=mktime($_POST['h'],$_POST['m'], $_POST['s'], $_POST['M'], $_POST['d'], $_POST['y']);
		$type=$_POST['type'];
		$isimg=$_POST['type1'];
		$model=M('article');
		$data=array(
			'title'=>$_POST['title'],
			'author'=>$_SESSION['online'],
			'content'=>$_POST['content'],
			'type'=>$type
			);
		if($time)
		{
				$data['pubtime']=$time;
		}
		else
		{
				$data['pubtime']=time();
		}
		$time=$data['pubtime'];
		if($isimg==1)//文章模式
		{
			$list = $model->add($data);
			if ($list !== false) {
				$this->success('发布成功！');
			} else {
				$this->error('发布失败!');
			}
		}
		else//图文模式
		{	if (!empty($_FILES)) //文件非空
			{
				switch($type)
				{
					case '活动动态图片':
						$this->picupload('300,80','150,80',$time,$type);
						break;
					case '首页图片切换':
						$this->picupload('300,80','180,80',$time,$type);
						break;
					case '信息公示图片':
						$this->picupload('250,80','150,80',$time,$type);
						break;
					case '业务介绍图片':
						$this->picupload('250,80','150,80',$time,$type);
						break;
					case '最美大厅':
						$this->picupload('200,80','120,80',$time,$type);
						break;
					default:
						$this->upactpic($time,$type);
						break;
				}
			}
		}

	}


	// 图片上传通用函数
    protected function picupload($width,$height,$time,$type) {
        import("@.ORG.UploadFile");
        //导入上传类
        $upload = new UploadFile();
        //设置上传文件大小
        $upload->maxSize = 3292200;
        //设置上传文件类型
        $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
        //设置附件上传目录
        $upload->savePath = './Public/Uploads/';
        //设置需要生成缩略图，仅对图像文件有效
        $upload->thumb = true;
        // 设置引用图片类库包路径
        $upload->imageClassPath = '@.ORG.Image';
        //设置需要生成缩略图的文件后缀
        $upload->thumbPrefix = 'm_,s_';  //生产2张缩略图
        //设置缩略图最大宽度
         $upload->thumbMaxWidth = $width;
        //设置缩略图最大高度
        $upload->thumbMaxHeight =$height;
        $upload->saveRule = uniqid;
        //删除原图
        $upload->thumbRemoveOrigin = true;
        if (!$upload->upload()) {
            //捕获上传异常
            $this->error($upload->getErrorMsg());
        } else {
            //取得成功上传的文件信息
            $uploadList = $upload->getUploadFileInfo();
            import("@.ORG.Image");
            //给m_缩略图添加水印, Image::water('原文件名','水印图片地址')
            Image::water($uploadList[0]['savepath'] . 'm_' . $uploadList[0]['savename'], '../Public/Images/logo2.png');
            $_POST['image'] = $uploadList[0]['savename'];
        }
        $model = M('article');
        //保存当前数据对象
		$data=array(
			'title'=>$_POST['title'],
			'author'=>$_SESSION['online'],
			'content'=>$_POST['content'],
			'pubtime'=>$time,
			'type'=>$type
			);
        $data['image'] = $_POST['image'];
        $list = $model->add($data);
        if ($list !== false) {
            $this->success('图文发布成功！');
        } else {
            $this->error('图文发布失败!');
        }
    }


	/*显示修改图文的函数，支持修改图片，文字，时间和分类。*/
	public function modifyarticle(){
		$this->login();
		$article=M('article');
		$cond['id']=$_GET['id'];
		$index=$article->where($cond)->select();
		//取得内容
		$data=array(
		'id'=>$index[0]['id'],
		'title'=>$index[0]['title'],
		'content'=>$index[0]['content'],
		'time'=>date("Y-m-d H:i:s",$index[0]['pubtime']),
		'time1'=>$index[0]['pubtime'],
		'type'=>$index[0]['type'],
		'image'=>$index[0]['image']
		);
		if($data['image']==''){
			$data['type1']='1';
		}
		else if($data['type']=='友情链接')
		{
			$data['type1']='0';
		}
		else
		{
			$data['type1']='2';
		}
		//dump($data);
		$this->assign('data',$data);
		$this->display();
	}

	/*进行修改操作的函数*/
	public function modarticle(){
		//dump($_POST);
		if($_POST['y']==''){
			$time=$_POST['time1'];
		}
		else
		{
			$time=mktime($_POST['h'],$_POST['m'], $_POST['s'], $_POST['M'], $_POST['d'], $_POST['y']);
		}
		//dump($time);
		$type=$_POST['type'];
		$isimg=$_POST['type1'];
		$model=M('article');
		$data=array(
			'title'=>$_POST['title'],
			'author'=>$_SESSION['online'],
			'content'=>$_POST['content'],
			'type'=>$type,
			'pubtime'=>$time
		);
		//dump($data);

		if($isimg==1)//文章模式
		{
			$cond['id']=$_POST['id'];
			$data['image']='';
			$list=$model->where($cond)->setField($data);
			if ($list !== false) {
				$this->success('修改成功！');
			} else {
				$this->error('修改失败!');
			}
		}
		else//图文模式
		{	if (!empty($_FILES)) //文件非空
			{
				switch($type)
				{
					case '活动动态图片':
						$this->picmodify('300,80','150,80',$data);
						break;
					case '首页图片切换':
						$this->picmodify('300,80','180,80',$data);
						break;
					case '信息公示图片':
						$this->picmodify('250,80','150,80',$data);
						break;
					case '业务介绍图片':
						$this->picmodify('250,80','150,80',$data);
						break;
					case '最美大厅':
						$this->picmodify('200,80','120,80',$data);
						break;
					default:
						$this->modifyactpic($data);
						break;
				}
			}
		}
	}
	/*更改图片的函数*/
	protected function picmodify($width,$height,$data) {
        import("@.ORG.UploadFile");
        //导入上传类
        $upload = new UploadFile();
        //设置上传文件大小
        $upload->maxSize = 3292200;
        //设置上传文件类型
        $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
        //设置附件上传目录
        $upload->savePath = './Public/Uploads/';
        //设置需要生成缩略图，仅对图像文件有效
        $upload->thumb = true;
        // 设置引用图片类库包路径
        $upload->imageClassPath = '@.ORG.Image';
        //设置需要生成缩略图的文件后缀
        $upload->thumbPrefix = 'm_,s_';  //生产2张缩略图
        //设置缩略图最大宽度
         $upload->thumbMaxWidth = $width;
        //设置缩略图最大高度
        $upload->thumbMaxHeight =$height;
        $upload->saveRule = uniqid;
        //删除原图
        $upload->thumbRemoveOrigin = true;
        if (!$upload->upload()) {
            //捕获上传异常
            //$this->error($upload->getErrorMsg());
        } else {
            //取得成功上传的文件信息
            $uploadList = $upload->getUploadFileInfo();
            import("@.ORG.Image");
            //给m_缩略图添加水印, Image::water('原文件名','水印图片地址')
            Image::water($uploadList[0]['savepath'] . 'm_' . $uploadList[0]['savename'], '../Public/Images/logo2.png');
            $_POST['image'] = $uploadList[0]['savename'];
        }
        $model = M('article');
		//dump($_POST['image']);
		//dump($data['image']);
		//dump($_POST['img']);
        //保存当前数据对象
		if($_POST['image']==null&&$_POST['img']==null)
		{
			//报错
			$this->error($upload->getErrorMsg());
		}
		else if($_POST['image']==null&&$_POST['img']!=null)
		{
			//图片不变
		}
		else
		{
			$data['image'] = $_POST['image'];
		}

		$cond['id']=$_POST['id'];
		$list=$model->where($cond)->setField($data);
		if ($list !== false) {
				$this->success('修改成功！');
		} else {
				$this->error('修改失败!');
		}
    }


/*---------通用文章列表操作---
-----------包括：-------------
----------------顶上来--------
----------------踩下去--------
----------------直接置顶------
----------------解除置顶------
----------------删除----------
----------------推送至首页----
----------------推送至公告----
------------------------------
*/
	//顶上来
	public function top(){
		$id=$_GET['id'];
		$model=M('article');
		$cond['id']=$id;
		$model->where($cond)->setInc('istop');
		$this->success('成功！');
	}
	//踩下去
	public function down(){
		$id=$_GET['id'];
		$model=M('article');
		$cond['id']=$id;
		$model->where($cond)->setDec('istop');
		$this->success('成功！');
	}


	//置顶
	public function totop(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'istop'=>999
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功！');
	}
	//解除置顶
	public function todown(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'istop'=>0
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功！');
	}

	//通用删除
	public function delete(){
		$article=M('article');
		$id=$_GET[id];
		$cond['id']=$id;
		$index=$article->where($cond)->select();
		if($index[0]['image']==='')//无图片，直接删除
		{
			$list=$article->where($cond)->delete();
			if($list)
			{
				$this->success('删除成功！');
			}
			else
			{
				$this->error('删除失败！');
			}
		}
		else//有图片
		{
			if($index[0]['type']=='多功能厅'||$index[0]['type']=='小剧场'||$index[0]['type']=='其他')
			{
				$myfile='./Public/Uploads/'.$index[0]['image'];
				if(file_exists($myfile))
				{
					$result=unlink($myfile);
					if($result)
					{
						$article->where($cond)->delete();
						$this->success('删除成功！');
					}
					else
					{
						$this->error('删除失败！');
					}
				}
			}
			else if($index[0]['type']!=0)
			{
				$myfilem='./Public/Uploads/m_'.$index[0]['image'];
				$myfiles='./Public/Uploads/s_'.$index[0]['image'];
				if(file_exists($myfilem)&&file_exists($myfiles))
				{
					$resultm=unlink($myfilem);
					$results=unlink($myfiles);
					if($resultm&&$results)
					{
						$article->where($cond)->delete();
						$this->success('删除成功！');
					}
					else
					{
						$this->error('删除失败！');
					}
				}
			}
			else
			{
				$article->where($cond)->delete();
				$this->success('文件不存在');
			}

		}

	}


	//推送到首页候选列表
	public function sendtoindex(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'isindex'=>2
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功,请到首页管理里面确认！');
	}
	//推送到首页
	public function toindex(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'isindex'=>1
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功');
	}
	//从首页撤下
	public function noindex(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'isindex'=>0
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功');
	}




	//推送到公告候选列表
	public function sendtogonggao(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'isgonggao'=>2
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功，请到首页管理里面确认！');
	}
	//推送到公告
	public function togonggao(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'isgonggao'=>1
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功！');
	}
	//解除公告
	public function nogonggao(){
		$this->login();//登陆
		$article=M('article');
		$data=array(
		'isgonggao'=>0
		);
		$cond['id']=$_GET['id'];
		$article->where($cond)->setField($data);
		$this->success('修改成功');
	}



	/*---------------学生活动列表*/
	public function act(){
		$this->login();
		$this->display();
	}
	//上传活动海报
    protected function upactpic($time,$type) {
        import("@.ORG.UploadFile");
        //导入上传类
        $upload = new UploadFile();
        //设置上传文件大小
        $upload->maxSize = 3292200;
        //设置上传文件类型
        $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
        //设置附件上传目录
        $upload->savePath = './Public/Uploads/';
        //设置需要生成缩略图，仅对图像文件有效
        $upload->thumb = false;
        // 设置引用图片类库包路径
        $upload->imageClassPath = '@.ORG.Image';
        $upload->saveRule = uniqid;
        //删除原图
        $upload->thumbRemoveOrigin = false;
        if (!$upload->upload()) {
            //捕获上传异常
            $this->error($upload->getErrorMsg());
        } else {
            //取得成功上传的文件信息
            $uploadList = $upload->getUploadFileInfo();
            $_POST['image'] = $uploadList[0]['savename'];
        }
        $model = M('article');
        //保存当前数据对象
		$data=array(
			'title'=>$_POST['title'],
			'author'=>$_SESSION['online'],
			'content'=>$_POST['content'],
			'pubtime'=>$time,
			'type'=>$type
			);
        $data['image'] = $_POST['image'];
        $list = $model->add($data);
        if ($list !== false) {
            $this->success('图文发布成功！');
        } else {
            $this->error('图文发布失败!');
        }
    }

	/*更改活动海报的函数*/
	protected function modifyactpic($data) {
        import("@.ORG.UploadFile");
        //导入上传类
        $upload = new UploadFile();
        //设置上传文件大小
        $upload->maxSize = 3292200;
        //设置上传文件类型
        $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
        //设置附件上传目录
        $upload->savePath = './Public/Uploads/';
        //设置需要生成缩略图，仅对图像文件有效
        $upload->thumb =false;
        // 设置引用图片类库包路径
        $upload->imageClassPath = '@.ORG.Image';

        $upload->saveRule = uniqid;
        //删除原图
        $upload->thumbRemoveOrigin = false;
        if (!$upload->upload()) {
            //捕获上传异常
            //$this->error($upload->getErrorMsg());
        } else {
            //取得成功上传的文件信息
            $uploadList = $upload->getUploadFileInfo();
            $_POST['image'] = $uploadList[0]['savename'];
        }
        $model = M('article');
		//dump($_POST['image']);
		//dump($data['image']);
		//dump($_POST['img']);
        //保存当前数据对象
		if($_POST['image']==null&&$_POST['img']==null)
		{
			//报错
			$this->error($upload->getErrorMsg());
		}
		else if($_POST['image']==null&&$_POST['img']!=null)
		{
			//图片不变
		}
		else
		{
			$data['image'] = $_POST['image'];
		}

		$cond['id']=$_POST['id'];
		$list=$model->where($cond)->setField($data);
		if ($list !== false) {
				$this->success('修改成功！');
		} else {
				$this->error('修改失败!');
		}
    }

	/*修改活动信息，支持修改图片，文字，时间和分类。*/
	public function modifyact(){
		$this->login();
		$article=M('article');
		$cond['id']=$_GET['id'];
		$index=$article->where($cond)->select();
		//取得内容
		$data=array(
		'id'=>$index[0]['id'],
		'title'=>$index[0]['title'],
		'content'=>$index[0]['content'],
		'time'=>date("Y-m-d H:i:s",$index[0]['pubtime']),
		'time1'=>$index[0]['pubtime'],
		'type'=>$index[0]['type'],
		'image'=>$index[0]['image']
		);
		if($data['image']==''){
			$data['type1']='1';
		}
		else if($data['type']=='友情链接')
		{
			$data['type1']='0';
		}
		else
		{
			$data['type1']='2';
		}
		//dump($data);
		$this->assign('data',$data);
		$this->display();
	}

	/*活动列表*/
	public function actlist(){
		$this->login();//登陆
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']=array('in','多功能厅,小剧场,其他');
		$index=$article->where($cond)->count();
		$Page = new Page($index,20);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
	}


	/*---------------会议列表*/
	public function meeting(){
		$this->login();
		$this->display();
	}

	public function meetinglist(){
		$this->login();//登陆
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']=array('in','国际会议,国内会议');
		$index=$article->where($cond)->count();
		$Page = new Page($index,20);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
	}

	public function modifymeeting(){
		$this->login();
		$article=M('article');
		$cond['id']=$_GET['id'];
		$index=$article->where($cond)->select();
		//取得内容
		$data=array(
		'id'=>$index[0]['id'],
		'title'=>$index[0]['title'],
		'content'=>$index[0]['content'],
		'time'=>date("Y-m-d H:i:s",$index[0]['pubtime']),
		'time1'=>$index[0]['pubtime'],
		'type'=>$index[0]['type']
		);

		//dump($data);
		$this->assign('data',$data);
		$this->display();
	}


	/*---------------通知*/

	public function notice(){
		$this->login();//登陆
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='通知公示';
		$index=$article->where($cond)->count();
		$Page = new Page($index,20);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
	}
	/*-----------通知*/


	/*---------------活动*/
	public function huodong(){
		$this->login();//登陆
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='活动动态';
		$cond1['type']='活动动态图片';
		$index=$article->where($cond)->count();
		$index1=$article->where($cond1)->count();
		$Page = new Page($index,10);//实例化分页类传入总记录数和每页显示的记录数
		$Page1 = new Page($index1,5);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		$show1 = $Page1->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		$list1 = $article->where($cond1)->order('istop DESC')->limit($Page1->firstRow.','.$Page1->listRows)->select();
		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		for($i=0;$i<count($list1);$i++){
			$list1[$i]['pubtime'] = date("Y-m-d h:i",$list1[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('list1',$list1);
		$this->assign('page',$show);//赋值分页输出
		$this->assign('page1',$show1);//赋值分页输出
		$this->display();
	}
	/*-----------活动*/



	/*-----------首页管理*/
	/*首页顶图控制*/
	public function indexpic(){
		$this->login();
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='首页顶图';
		$cond['image']=array('neq','null');
		$index=$article->where($cond)->count();
		$Page = new Page($index,2);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
	}
	//上传首页顶图
	public function addindexpic(){
		if (!empty($_FILES)) //文件非空
		{
			$this->upindexpic();
		}else{
			$this->error('请选择图片！');
		}
	}

	//图片上传通用函数
    protected function upindexpic() {
        import("@.ORG.UploadFile");
        //导入上传类
        $upload = new UploadFile();
        //设置上传文件大小
        $upload->maxSize = 3292200;
        //设置上传文件类型
        $upload->allowExts = explode(',', 'jpg,gif,png,jpeg');
        //设置附件上传目录
        $upload->savePath = './Public/img/Index/';
        //设置需要生成缩略图，仅对图像文件有效
        $upload->thumb = false;
        // 设置引用图片类库包路径
        $upload->imageClassPath = '@.ORG.Image';
        //$upload->saveRule = uniqid;
        //删除原图
        $upload->thumbRemoveOrigin = false;
        if (!$upload->upload()) {
            //捕获上传异常
            $this->error($upload->getErrorMsg());
        } else {
            //取得成功上传的文件信息
            $uploadList = $upload->getUploadFileInfo();
            $_POST['image'] = $uploadList[0]['savename'];
        }
        $model = M('article');
        //保存当前数据对象
		$data=array(
			'title'=>$_POST['title'],
			'author'=>$_SESSION['online'],
			'content'=>$_POST['content'],
			'pubtime'=>time(),
			'type'=>'首页顶图'
			);
        $data['image'] = $_POST['image'];
        $list = $model->add($data);
        if ($list !== false) {
            $this->success('图文发布成功！');
        } else {
            $this->error('图文发布失败!');
        }
    }

	public function deletepic(){
		$article=M('article');
		$id=$_GET[id];
		$cond['id']=$id;
		$index=$article->where($cond)->select();
		$myfile='./Public/img/Index/'.$index[0]['image'];
		if(file_exists($myfile))
		{
			$result=unlink($myfile);
			if($result){
				$article->where($cond)->delete();
				$this->success('删除成功！');
			}
		}
		else{
			$this->success('文件已删除');
		}
	}


	/*首页图片切换*/
	public function intropic(){
		$this->login();
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='首页图片切换';
		$cond['image']=array('neq','null');
		$index=$article->where($cond)->count();
		$Page = new Page($index,5);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
	}



	public function noticepic(){
		$this->login();
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='信息公示图片';
		$index=$article->where($cond)->count();
		$Page = new Page($index,3);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
	}



	public function noticelink(){
		$this->login();//登陆
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond1['isindex']=1;
		$cond2['isindex']=2;
		$cond1['image']=array('eq','');
		$cond1['type']=array('neq','大厅简介');
		$cond2['image']=array('eq','');
		$cond2['type']=array('neq','大厅简介');
		$index1=$article->where($cond)->count();
		$index2=$article->where($cond)->count();
		$Page1 = new Page($index1,5);//实例化分页类传入总记录数和每页显示的记录数
		$Page2 = new Page($index2,5);//实例化分页类传入总记录数和每页显示的记录数
		$show1 = $Page1->show();//分页显示输出
		$show2 = $Page2->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list1 = $article->where($cond1)->order('istop DESC')->limit($Page1->firstRow.','.$Page1->listRows)->select();
		$list2 = $article->where($cond2)->order('istop DESC')->limit($Page2->firstRow.','.$Page2->listRows)->select();
		for($i=0;$i<count($list1);$i++){
			$list1[$i]['pubtime'] = 	date("Y-m-d h:i",$list1[$i]['pubtime']);
		}
		for($i=0;$i<count($list2);$i++){
			$list2[$i]['pubtime'] = 	date("Y-m-d h:i",$list2[$i]['pubtime']);
		}
		$this->assign('list1',$list1);
		$this->assign('list2',$list2);
		$this->assign('page1',$show1);//赋值分页输出
		$this->assign('page2',$show2);
		$this->display();
	}

	public function noticecolor(){
		$id=$_GET['id'];
		$color=$_GET['color'];
		$article=M('article');
		$cond['id']=$id;
		$data['url']=$color;
		$article->where($cond)->setField($data);
		$this->success('修改成功！');
	}

	public function nocolor(){
		$id=$_GET['id'];
		$color=$_GET['color'];
		$article=M('article');
		$cond['id']=$id;
		$data['url']=$_SESSION['null'];
		$article->where($cond)->setField($data);
		$this->success('修改成功！');
	}

	public function servicepic(){
		$this->login();
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond['type']='业务介绍图片';
		$index=$article->where($cond)->count();
		$Page = new Page($index,3);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();

		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] = 	date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
		$this->display();
	}

	public function servicelink(){
		$this->login();//登陆
		if($_GET['id']==null){
			$this->showservice();
		}
		else{
			$this->modservice();
			$this->showservice();
		}
		$this->display();
	}
	private function showservice(){
		$article=M('article');
		$cond['type']='业务介绍';
		import("ORG.Util.Page");//导入分页类
		$index=$article->where($cond)->count();
		$Page = new Page($index,3);//实例化分页类传入总记录数和每页显示的记录数
		$show = $Page->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list = $article->where($cond)->order('istop DESC')->limit($Page->firstRow.','.$Page->listRows)->select();
		for($i=0;$i<count($list);$i++){
			$list[$i]['pubtime'] =date("Y-m-d H:i",$list[$i]['pubtime']);
		}
		$this->assign('list',$list);
		$this->assign('page',$show);//赋值分页输出
	}

	public function newservice(){
		$this->login();
		$model = M('article');
        //保存当前数据对象
		$data=array(
			'title'=>$_POST['title'],
			'author'=>$_SESSION['online'],
			'content'=>$_POST['content'],
			'pubtime'=>time(),
			'type'=>'业务介绍',
			'image'=>$_POST['image']
			);
		if($_POST['id']!=null){
			$cond['id']=$_POST['id'];
			$model->where($cond)->setField($data);
		}
		else{
			$data['id']=$_POST['id'];
			$list = $model->add($data);
		}

		if ($list !== false) {
            $this->success('发布成功！');
        } else {
            $this->error('发布失败!');
        }
	}
	private function modservice(){
		$cond['id']=$_GET['id'];
		$model=M('article');
		$index=$model->where($cond)->select();
		$this->assign('id',$index[0]['id']);
		$this->assign('title',$index[0]['title']);
		$this->assign('content',$index[0]['content']);
	}
	/*---------------业务介绍*/


	/*公告----------*/
	public function gonggao(){
		$this->login();//登陆
		$article=M('article');
		import("ORG.Util.Page");//导入分页类
		$cond1['isgonggao']=1;
		$cond2['isgonggao']=2;
		$index1=$article->where($cond1)->count();
		$index2=$article->where($cond2)->count();
		$Page1 = new Page($index1,10);//实例化分页类传入总记录数和每页显示的记录数
		$Page2 = new Page($index2,10);//实例化分页类传入总记录数和每页显示的记录数
		$show1 = $Page1->show();//分页显示输出
		$show2 = $Page2->show();//分页显示输出
		//进行分页数据查询注意limit方法的参数要使用Page类的属性
		$list1 = $article->where($cond1)->order('istop DESC')->limit($Page1->firstRow.','.$Page1->listRows)->select();
		$list2 = $article->where($cond2)->order('istop DESC')->limit($Page2->firstRow.','.$Page2->listRows)->select();
		for($i=0;$i<count($list1);$i++){
			$list1[$i]['pubtime'] = 	date("Y-m-d h:i",$list1[$i]['pubtime']);
		}
		for($i=0;$i<count($list2);$i++){
			$list2[$i]['pubtime'] = 	date("Y-m-d h:i",$list2[$i]['pubtime']);
		}
		$this->assign('list1',$list1);
		$this->assign('list2',$list2);
		$this->assign('page1',$show1);//赋值分页输出
		$this->assign('page2',$show2);
		$this->display();
	}
	public function addgonggao(){
		$this->login();
		if($_POST['title']==null){
			 $this->error('通知不能为空！');
		}
		$model = M('article');
        //保存当前数据对象
		$data=array(
			'title'=>$_POST['title'],
			'author'=>$_SESSION['online'],
			'pubtime'=>time(),
			'isgonggao'=>1
			);
        $list = $model->add($data);
		if ($list !== false) {
            $this->success('发布成功！');
        } else {
            $this->error('发布失败!');
        }
	}


	public function login(){
		$this->	checkLogin();
		$username=$_SESSION['online'];
		if($_SESSION['power']==0){
			$this->assign('username',$username);
			$this->assign('power','超级管理员');
		}
		if($_SESSION['power']==1){
			$this->assign('username',$username);
			$this->assign('power','管理员');
		}
	}
	public function logout()
	{
		$this->	checkLogin();
		Session::clear();
		$this->assign('jumpUrl','__APP__');
		$this->assign('waitSecond',2);
		$this->success('退出成功！');
	}
}